package so;

import ivan.bookKeeper.database.DatabaseHandler;
import android.content.Context;
import android.os.AsyncTask;
import android.widget.Toast;

public class GeneralSystemOperation extends AsyncTask<Object, Object, Object> {
	protected DatabaseHandler dbHandler;
	protected Context context;
	protected Toast toast;
	protected String toastMessage = "";
	
	public GeneralSystemOperation(Context context) {
		this.context = context;
	}

	// prepare system operation, open the database handler etc
	@Override
	protected void onPreExecute() {
		super.onPreExecute();
		dbHandler = new DatabaseHandler(context);
	}
	
	// do stuff after the work is done, show toast message, close db etc
	@Override
	protected void onPostExecute(Object result) {
		super.onPostExecute(result);
		toast = Toast.makeText(context, toastMessage, Toast.LENGTH_SHORT);
		toast.show();
		dbHandler.close();
	}

	// implement specifics of this method in subclasses!!
	@Override
	protected Object doInBackground(Object... params) {
		// TODO Auto-generated method stub
		
		return null;
	}
}
